#include<stack>
class MinStack {
public:
    std::stack<int> s;
    std::stack<int> mins;
    MinStack() {

    }

    void push(int val) {
        s.push(val);
        if (mins.empty()) {
            mins.push(val);
        }
        else {
            int min = mins.top();
            if (val < min) mins.push(val);
            else mins.push(min);
        }
    }

    void pop() {
        s.pop();
        mins.pop();
    }

    int top() {
        return s.top();
    }

    int getMin() {
        return mins.top();
    }
};